package TopSky.IOT.JUnit.XStream;



import org.junit.Test;

import com.thoughtworks.xstream.XStream;
import TopSky.IOT.Models.XStream.controldevice;

public class ControlDevice {

	@Test
	public void test() {
		controldevice model=new controldevice();
		model.setErrorCode("labsID");
		model.setMessage("没有LabsId");
		model.setLabsID(1);
		model.setName("hai");
        XStream xstream=new XStream();
        //XStream xstream=new XStream(new DomDriver()); //直接用jaxp dom来解释
        //XStream xstream=new XStream(new DomDriver("utf-8")); //指定编码解析器,直接用jaxp dom来解释
      
      ////如果没有这句，xml中的根元素会是<包.类名>；或者说：注解根本就没生效，所以的元素名就是类的属性
      xstream.processAnnotations(model.getClass()); //通过注解方式的，一定要有这句话
      System.out.println(xstream.toXML(model));
	}
}
